//
//  LHXbutton.m
//  Etwo
//
//  Created by 林浩翔 on 16/6/17.
//  Copyright © 2016年 林浩翔. All rights reserved.
//

#import "LHXbutton.h"
#import "LHXBtnItem.h"

@interface LHXbutton ()



@end

@implementation LHXbutton

- (void)setItem:(LHXBtnItem *)item{
    _item = item;
    self.btnTitle.text = item.btn_title;
    self.btnTextTag = item.btn_titletag;
    [self setBackgroundImage:[UIImage imageNamed:item.btn_backgroundPicture] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageNamed:item.btn_highlight] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[UIImage imageNamed:item.btn_enble] forState:UIControlStateDisabled];
    
//    [self setImage:[UIImage imageNamed:item.btn_btnPicture] forState:UIControlStateNormal];
    
    
}

+ (instancetype)btn{
    LHXbutton *btn = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil]lastObject];
    
    btn.backgroundColor = [UIColor clearColor];

    
    [btn addTarget:btn action:@selector(btnOut:) forControlEvents:UIControlEventTouchCancel];
    
    return btn;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    

}

- (void)btnOut:(LHXbutton *)btn{
    
    [UIView animateWithDuration:0.1 animations:^{
        
        self.transform = CGAffineTransformMakeScale(1.0, 1.0);
        
        self.alpha = 1;
        
    }];
}

#pragma mark --按钮高亮动画
- (void)setHighlighted:(BOOL)highlighted{
    [super setHighlighted:highlighted];
    
    if (highlighted) {
        
        [UIView animateWithDuration:0.1 animations:^{
            
            self.transform = CGAffineTransformMakeScale(1.2, 1.2);
            
        }];
        
        
    }else{

        [UIView animateWithDuration:0.1 animations:^{
            
            self.transform = CGAffineTransformMakeScale(1.0, 1.0);
            
        }];
    }
    
}




@end
